from django.conf.urls import url
from rest_framework_jwt.views import obtain_jwt_token

from .views import statistical, users, specs, images, skus, orders, permissions, groups, admins

from rest_framework.routers import DefaultRouter

urlpatterns = [
    url(r'^authorizations/$', obtain_jwt_token),
    # 等价于上边的写法
    # url(r'^authorizations/$', obtain_jwt_token.as_view()),

    # -------------------数据统计-----------------------
    #     统计注册用户总数
    url(r'^statistical/total_count/$', statistical.UserCountView.as_view()),
    # 日增用户统计
    url(r'^statistical/day_increment/$', statistical.UserDayCountView.as_view()),
    # 当天登陆用户统计
    url(r'^statistical/day_active/$', statistical.UserDayActiveCountView.as_view()),
    # 当天下单用户统计
    url(r'^statistical/day_orders/$', statistical.UserOrderCountView.as_view()),
    # 月增用户统计
    url(r'^statistical/month_increment/$', statistical.UserMonthCountView.as_view()),
    # 商品访问量统计
    url(r'^statistical/goods_day_views/$', statistical.GoodsTypeCountView.as_view()),

    # -------------------用户表管理-----------------------

    url(r'users/$', users.UserView.as_view()),

    # ----------------商品规格---------------------
    # 获取SKU简单信息
    url(r'^goods/simple/$', specs.SpecsView.as_view({'get': 'simple'})),

    # ----------------商品图片---------------------
    # 获取图片
    url(r'^skus/simple/$', images.ImageView.as_view({'get': 'simple'})),

    # ----------------商品SKU---------------------
    # 获取商品规格信息
    url(r'^goods/(?P<pk>\d+)/specs/$', skus.SKUView.as_view({'get': 'specs'})),

    # ----------------权限管理---------------------
    # 获取权限类型
    url(r'^permission/content_types/$', permissions.PermissionView.as_view({'get': 'content_types'})),

    # ----------------权限信息---------------------
    # 获取权限简单信息
    url(r'^permission/simple/$', groups.GroupView.as_view({'get': 'simple'})),
    # ----------------分组信息---------------------
    # 获取分组信息
    url(r'^permission/groups/simple/$', admins.AdminView.as_view({'get': 'simple'})),

]

# --------------------视图集------------------------
# --------------------商品规格表------------------------
router = DefaultRouter()
router.register('goods/specs', specs.SpecsView, base_name='specs')
urlpatterns += router.urls

# --------------------商品图片------------------------
router = DefaultRouter()
router.register('skus/images', images.ImageView, base_name='images')
urlpatterns += router.urls

# --------------------商品SKU表------------------------
router = DefaultRouter()
router.register('skus', skus.SKUView, base_name='skus')
urlpatterns += router.urls

# --------------------商品订单表------------------------
router = DefaultRouter()
router.register('orders', orders.OrderInfoView, base_name='orders')
urlpatterns += router.urls

# --------------------权限------------------------
router = DefaultRouter()
router.register('permission/perms', permissions.PermissionView, base_name='perms')
urlpatterns += router.urls

# --------------------分组------------------------
router = DefaultRouter()
router.register('permission/groups', groups.GroupView, base_name='groups')
urlpatterns += router.urls

# --------------------管理员------------------------
router = DefaultRouter()
router.register('permission/admins', admins.AdminView, base_name='admins')
urlpatterns += router.urls
